/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ep.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Spyros
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@Entity
@Table(name = "t007_illness", catalog = "epresc", schema = "")
@NamedQueries({
    @NamedQuery(name = "T007Illness.findAll", query = "SELECT t FROM T007Illness t"),
    @NamedQuery(name = "T007Illness.findById", query = "SELECT t FROM T007Illness t WHERE t.id = :id"),
    @NamedQuery(name = "T007Illness.findByCode", query = "SELECT t FROM T007Illness t WHERE t.code = :code"),
    @NamedQuery(name = "T007Illness.findByName", query = "SELECT t FROM T007Illness t WHERE t.name = :name")})
public class T007Illness implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "code")
    private String code;
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "t007Illness")
    private Collection<T005T007> t005T007Collection;
    @ManyToMany
    @JoinTable(name = "t007_t010",
    joinColumns =
    @JoinColumn(name = "t007_illness_id"),
    inverseJoinColumns =
    @JoinColumn(name = "t010_substance_id"))
    private Collection<T010Substance> t010Substances;

    public T007Illness() {
    }

    public T007Illness(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<T005T007> getT005T007Collection() {
        return t005T007Collection;
    }

    public void setT005T007Collection(Collection<T005T007> t005T007Collection) {
        this.t005T007Collection = t005T007Collection;
    }

//    @XmlTransient
    public Collection<T010Substance> getT010Substances() {
        return t010Substances;
    }

    public void setT010Substances(Collection<T010Substance> t010Substances) {
        this.t010Substances = t010Substances;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof T007Illness)) {
            return false;
        }
        T007Illness other = (T007Illness) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return code + "-" + name;
    }
}
